package br.ufpe.cin.analysis.plugin.models;

import java.io.FileNotFoundException;
import java.io.IOException;

import javax.xml.bind.JAXBException;

import org.jfree.data.general.DefaultPieDataset;

import br.ufpe.cin.analysis.plugin.entities.Activity;
import br.ufpe.cin.analysis.plugin.entities.Metric;
import br.ufpe.cin.analysis.plugin.entities.Process;

public class PieDataset extends ChartDataset<DefaultPieDataset>{

	public PieDataset(String xmlFileName) throws JAXBException, IOException
	{
		super(xmlFileName);
	}

	public PieDataset(Process process)
	{
		super(process);
	}
	
	public PieDataset(Process process, String xmlFile)
	{
		super(process, xmlFile);
	}

	public PieDataset()
	{
		super();
	}


	@Override
	public void makeJFreeChartDataset() {

		this.setJFreeChartDataset(new DefaultPieDataset() );

		for( Activity ac : this.getProcess().getActivities() )
		{
			if( ac.getSelected() ){
				for(Metric m : ac.getMetrics() )
				{
					if(m.getSelected()) this.getJFreeChartDataset().setValue(ac.getName() + ": " + m.getName(), m.getValue());
				}
			}
		}

	}



}
